home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue54 / Persist / Adrs_Srv.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2000-01-23  |  19.2 KB  |  601 lines

  1. {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  2.   (c) TechInsite Pty. Ltd.
  3.   PO Box 429, Abbotsford, Melbourne. 3067 Australia
  4.   Phone: +61 3 9419 6456
  5.   Fax:   +61 3 9419 1682
  6.   Web:   www.techinsite.com.au
  7.   EMail: peter_hinrichsen@techinsite.com.au
  8.  
  9.   Created: Jan 2000
  10.  
  11.   Notes: Family of visitors to manage mapping of
  12.          address book classes to Interbase
  13.  
  14. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
  15. unit Adrs_Srv;
  16.  
  17. interface
  18. uses
  19.   tiPtnVisitorDB
  20.   ;
  21.  
  22. type
  23.  
  24.   // Read the primary keys of all the people in the database
  25.   //----------------------------------------------------------------------------
  26.   TVisPersonRead_PK = class( TVisDBSelect )
  27.   protected
  28.     function    AcceptVisitor : boolean ; override ;
  29.     procedure   Init                    ; override ;
  30.     procedure   MapRowsToObject         ; override ;
  31.   end ;
  32.  
  33.   // Read the details of one person
  34.   //----------------------------------------------------------------------------
  35.   TVisPersonRead_Detail = class( TVisDBSelect )
  36.   protected
  37.     function    AcceptVisitor : boolean ; override ;
  38.     procedure   Init                    ; override ;
  39.     procedure   SetupParams             ; override ;
  40.     procedure   MapRowsToObject         ; override ;
  41.   end ;
  42.  
  43.   // Update a person
  44.   //----------------------------------------------------------------------------
  45.   TVisPersonUpdate = class( TVisDBUpdate )
  46.   protected
  47.     function    AcceptVisitor : boolean ; override ;
  48.     procedure   Init                    ; override ;
  49.     procedure   SetupParams             ; override ;
  50.     procedure   UpdateObject            ; override ;
  51.   end ;
  52.  
  53.   // Delete a person
  54.   //----------------------------------------------------------------------------
  55.   TVisPersonDelete = class( TVisDBUpdate )
  56.   protected
  57.     function    AcceptVisitor : boolean ; override ;
  58.     procedure   Init                    ; override ;
  59.     procedure   SetupParams             ; override ;
  60.     procedure   UpdateObject            ; override ;
  61.   end ;
  62.  
  63.   // Insert a new person
  64.   //----------------------------------------------------------------------------
  65.   TVisPersonCreate = class( TVisDBUpdate )
  66.   protected
  67.     function    AcceptVisitor : boolean ; override ;
  68.     procedure   Init                    ; override ;
  69.     procedure   SetupParams             ; override ;
  70.     procedure   UpdateObject            ; override ;
  71.   end ;
  72.  
  73.   // Read all the address(es) for a person
  74.   //----------------------------------------------------------------------------
  75.   TVisAdrsRead = class( TVisDBSelect )
  76.   protected
  77.     function    AcceptVisitor : boolean ; override ;
  78.     procedure   Init                    ; override ;
  79.     procedure   SetupParams             ; override ;
  80.     procedure   MapRowsToObject         ; override ;
  81.   end ;
  82.  
  83.   // Read all the EAddress(es) for a person
  84.   //----------------------------------------------------------------------------
  85.   TVisEAdrsRead = class( TVisDBSelect )
  86.   protected
  87.     function    AcceptVisitor : boolean ; override ;
  88.     procedure   Init                    ; override ;
  89.     procedure   SetupParams             ; override ;
  90.     procedure   MapRowsToObject         ; override ;
  91.   end ;
  92.  
  93.   // Insert a new EAddress
  94.   //----------------------------------------------------------------------------
  95.   TVisEAdrsCreate = class( TVisDBUpdate )
  96.   private
  97.   protected
  98.     function    AcceptVisitor : boolean ; override ;
  99.     procedure   Init                    ; override ;
  100.     procedure   SetupParams             ; override ;
  101.     procedure   UpdateObject            ; override ;
  102.   end ;
  103.  
  104.   // Update an existing EAddress
  105.   //----------------------------------------------------------------------------
  106.   TVisEAdrsUpdate = class( TVisDBUpdate )
  107.   private
  108.   protected
  109.     function    AcceptVisitor : boolean ; override ;
  110.     procedure   Init                    ; override ;
  111.     procedure   SetupParams             ; override ;
  112.     procedure   UpdateObject            ; override ;
  113.   end ;
  114.  
  115.   // Delete an EAddress
  116.   //----------------------------------------------------------------------------
  117.   TVisEAdrsDelete = class( TVisDBUpdate )
  118.   private
  119.   protected
  120.     function    AcceptVisitor : boolean ; override ;
  121.     procedure   Init                    ; override ;
  122.     procedure   SetupParams             ; override ;
  123.     procedure   UpdateObject            ; override ;
  124.   end ;
  125.  
  126.   // Insert a new address
  127.   //----------------------------------------------------------------------------
  128.   TVisAdrsCreate = class( TVisDBUpdate )
  129.   private
  130.   protected
  131.     function    AcceptVisitor : boolean ; override ;
  132.     procedure   Init                    ; override ;
  133.     procedure   SetupParams             ; override ;
  134.     procedure   UpdateObject            ; override ;
  135.   end ;
  136.  
  137.   //----------------------------------------------------------------------------
  138.   TVisAdrsUpdate = class( TVisDBUpdate )
  139.   private
  140.   protected
  141.     function    AcceptVisitor : boolean ; override ;
  142.     procedure   Init                    ; override ;
  143.     procedure   SetupParams             ; override ;
  144.     procedure   UpdateObject            ; override ;
  145.   end ;
  146.  
  147.   //----------------------------------------------------------------------------
  148.   TVisAdrsDelete = class( TVisDBUpdate )
  149.   private
  150.   protected
  151.     function    AcceptVisitor : boolean ; override ;
  152.     procedure   Init                    ; override ;
  153.     procedure   SetupParams             ; override ;
  154.     procedure   UpdateObject            ; override ;
  155.   end ;
  156.  
  157.  
  158. implementation
  159. uses
  160.   Adrs_BOM
  161.   ,tiPtnVisitorMgr
  162.   ,tiPtnVisitor
  163.   ,tiPerObjAbs
  164.   ,cAdrs
  165.   ,cSQL
  166.   ,tiUtils
  167.   ;
  168.  
  169. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  170. // *
  171. // * TVisPersonRead
  172. // *
  173. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  174. function TVisPersonRead_PK.AcceptVisitor: boolean;
  175. begin
  176.   result := ( Visited is TPersonList ) ;
  177. end;
  178.  
  179. procedure TVisPersonRead_PK.Init;
  180. begin
  181.   Query.SQL.Text := cSQLPersonRead_PK ;
  182. end;
  183.  
  184. procedure TVisPersonRead_PK.MapRowsToObject;
  185. var
  186.   lData : TPerson ;
  187. begin
  188.   lData             := TPerson.Create ;
  189.   lData.OID         := Query.FieldByName( 'OID' ).AsInteger ;
  190.   lData.LastName    := Query.FieldByName( 'Last_Name' ).AsString ;
  191.   lData.FirstName   := Query.FieldByName( 'First_Name' ).AsString ;
  192.   lData.ObjectState := posPK ;
  193.   TVisList( Visited ).Add( lData ) ;
  194. end ;
  195.  
  196. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  197. // *
  198. // * TVisAdrsRead
  199. // *
  200. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  201. function TVisAdrsRead.AcceptVisitor: boolean;
  202. begin
  203.   result := ( Visited is TPerson ) and
  204.             ( TPerson( Visited ).ObjectState = posPK ) ;
  205.  
  206. end;
  207.  
  208. procedure TVisAdrsRead.Init;
  209. begin
  210.   Query.SQL.Text := cSQLPersonAddressRead ;
  211. end;
  212.  
  213. procedure TVisAdrsRead.MapRowsToObject;
  214. var
  215.   lData : TAddress ;
  216. begin
  217.   lData := TAddress.Create ;
  218.   lData.OID      := Query.FieldByName( 'OID'       ).AsInteger ;
  219.   lData.AdrsType := Query.FieldByName( 'Adrs_Type' ).AsString  ;
  220.   lData.Lines    := Query.FieldByName( 'Lines'     ).AsString  ;
  221.   lData.State    := Query.FieldByName( 'State'     ).AsString  ;
  222.   lData.PCode    := Query.FieldByName( 'PCode'     ).AsString  ;
  223.   lData.Country  := Query.FieldByName( 'Country'   ).AsString  ;
  224.   lData.Owner    := TPerson( Visited ) ;
  225.   TPerson( Visited ).AddressList.Add( lData ) ;
  226. end;
  227.  
  228. procedure TVisAdrsRead.SetupParams;
  229. begin
  230.   TPerson( Visited ).AddressList.Clear ;
  231.   Query.ParamByName( 'owner_oid' ).AsInteger := TPerson( Visited ).OID ;
  232. end;
  233.  
  234. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  235. // *
  236. // * TVisEAdrsRead
  237. // *
  238. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  239. function TVisEAdrsRead.AcceptVisitor: boolean;
  240. begin
  241.   result := ( Visited is TPerson ) and
  242.             ( TPerson( Visited ).ObjectState = posPK ) ;
  243. end;
  244.  
  245. procedure TVisEAdrsRead.Init;
  246. begin
  247.   Query.SQL.Text := cSQLPersonEAddressRead ;
  248. end;
  249.  
  250. procedure TVisEAdrsRead.MapRowsToObject;
  251. var
  252.   lData : TEAddress ;
  253. begin
  254.   lData := TEAddress.Create ;
  255.   lData.OID       := Query.FieldByName( 'OID'       ).AsInteger ;
  256.   lData.EAdrsType := Query.FieldByName( 'EAdrs_Type' ).AsString ;
  257.   lData.Text      := Query.FieldByName( 'Text'     ).AsString ;
  258.   lData.Owner     := TPerson( Visited );
  259.   TPerson( Visited ).EAddressList.Add( lData ) ;
  260. end;
  261.  
  262. procedure TVisEAdrsRead.SetupParams;
  263. begin
  264.   TPerson( Visited ).EAddressList.Clear ;
  265.   Query.ParamByName( 'owner_oid' ).AsInteger := TPerson( Visited ).OID ;
  266. end;
  267.  
  268. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  269. // *
  270. // * TVisPersonRead_Detail
  271. // *
  272. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  273. function TVisPersonRead_Detail.AcceptVisitor: boolean;
  274. begin
  275.   result := ( Visited is TPerson ) and
  276.             ( TPerObjAbs( Visited ).ObjectState = posPK ) ;
  277. end;
  278.  
  279. // -----------------------------------------------------------------------------
  280. procedure TVisPersonRead_Detail.Init;
  281. begin
  282.   Query.SQL.Text := cSQLPersonRead_Detail ;
  283. end;
  284.  
  285. // -----------------------------------------------------------------------------
  286. procedure TVisPersonRead_Detail.MapRowsToObject;
  287. begin
  288.   with Visited as TPerson do begin
  289.     Title    := Query.FieldByName( 'Title' ).AsString ;
  290.     Initials := Query.FieldByName( 'Initials' ).AsString ;
  291.     Notes    := Query.FieldByName( 'Notes' ).AsString ;
  292.     ObjectState := posClean ;
  293.   end ;
  294. end;
  295.  
  296. // -----------------------------------------------------------------------------
  297. procedure TVisPersonRead_Detail.SetupParams;
  298. begin
  299.   Query.ParamByName( 'OID' ).AsInteger := TPerson( Visited ).OID ;
  300. end ;
  301.  
  302. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  303. // *
  304. // * TVisPersonUpate
  305. // *
  306. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  307. function TVisPersonUpdate.AcceptVisitor: boolean;
  308. begin
  309.   result := ( Visited is TPerson ) and
  310.             ( TPerson( Visited ).ObjectState = posUpdate ) ;
  311. end;
  312.  
  313. procedure TVisPersonUpdate.Init;
  314. begin
  315.   Query.SQL.Text := cSQLPersonUpdate ;
  316. end;
  317.  
  318. procedure TVisPersonUpdate.SetupParams;
  319. begin
  320.   Query.ParamByName( 'OID' ).AsInteger       := TPerson( Visited ).OID ;
  321.   Query.ParamByName( 'First_Name' ).AsString := TPerson( Visited ).FirstName ;
  322.   Query.ParamByName( 'Last_Name' ).AsString  := TPerson( Visited ).LastName ;
  323.   Query.ParamByName( 'Title' ).AsString      := TPerson( Visited ).Title ;
  324.   Query.ParamByName( 'Initials' ).AsString   := TPerson( Visited ).Initials ;
  325.   Query.ParamByName( 'Notes' ).AsString      := TPerson( Visited ).Notes ;
  326. end;
  327.  
  328. procedure TVisPersonUpdate.UpdateObject;
  329. begin
  330.   TPerson( Visited ).ObjectState := posClean ;
  331. end;
  332.  
  333. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  334. // *
  335. // * TVisPersonDelete
  336. // *
  337. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  338. function TVisPersonDelete.AcceptVisitor: boolean;
  339. begin
  340.   result := ( Visited is TPerson ) and
  341.             ( TPerson( Visited ).ObjectState = posDelete ) ;
  342. end;
  343.  
  344. procedure TVisPersonDelete.Init;
  345. begin
  346.   Query.SQL.Text := cSQLPersonDelete ;
  347. end;
  348.  
  349. procedure TVisPersonDelete.SetupParams;
  350. begin
  351.   Query.ParamByName( 'OID' ).AsInteger       := TPerson( Visited ).OID ;
  352. end;
  353.  
  354. procedure TVisPersonDelete.UpdateObject;
  355. begin
  356.   TPerson( Visited ).ObjectState := posClean ;
  357. end;
  358.  
  359. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  360. // *
  361. // * TVisPersonCreate
  362. // *
  363. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  364. function TVisPersonCreate.AcceptVisitor: boolean;
  365. begin
  366.   result := ( Visited is TPerson ) and
  367.             ( TPerson( Visited ).ObjectState = posCreate ) ;
  368. end;
  369.  
  370. procedure TVisPersonCreate.Init;
  371. begin
  372.   Query.SQL.Text := cSQLPersonCreate ;
  373. end;
  374.  
  375. procedure TVisPersonCreate.SetupParams;
  376. begin
  377.   Query.ParamByName( 'OID' ).AsInteger       := TPerson( Visited ).OID ;
  378.   Query.ParamByName( 'First_Name' ).AsString := TPerson( Visited ).FirstName ;
  379.   Query.ParamByName( 'Last_Name' ).AsString  := TPerson( Visited ).LastName ;
  380.   Query.ParamByName( 'Title' ).AsString      := TPerson( Visited ).Title ;
  381.   Query.ParamByName( 'Initials' ).AsString   := TPerson( Visited ).Initials ;
  382.   Query.ParamByName( 'Notes' ).AsString      := TPerson( Visited ).Notes ;
  383. end;
  384.  
  385. procedure TVisPersonCreate.UpdateObject;
  386. begin
  387.   TPerson( Visited ).ObjectState := posClean ;
  388. end;
  389.  
  390. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  391. // *
  392. // * TVisEAdrsCreate
  393. // *
  394. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  395. function TVisEAdrsCreate.AcceptVisitor: boolean;
  396. begin
  397.   result := ( Visited is TEAddress ) and
  398.             ( TEAddress( Visited ).ObjectState = posCreate ) ;
  399. end;
  400.  
  401. procedure TVisEAdrsCreate.Init;
  402. begin
  403.   Query.SQL.Text := cSQLPersonEAddressCreate ;
  404. end;
  405.  
  406. procedure TVisEAdrsCreate.SetupParams;
  407. begin
  408.   with Visited as TEAddress do begin
  409.     Query.ParamByName( 'OID' ).AsInteger       := OID ;
  410.     Query.ParamByName( 'Owner_OID' ).AsInteger := Owner.OID ;
  411.     Query.ParamByName( 'EAdrs_Type' ).AsString := EAdrsType ;
  412.     Query.ParamByName( 'Text' ).AsString       := Text ;
  413.   end ;
  414. end;
  415.  
  416. procedure TVisEAdrsCreate.UpdateObject ;
  417. begin
  418.   TEAddress( Visited ).ObjectState := posClean ;
  419. end ;
  420.  
  421. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  422. // *
  423. // * TVisEAdrsDelete
  424. // *
  425. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  426. function TVisEAdrsDelete.AcceptVisitor: boolean;
  427. begin
  428.   result := ( Visited is TEAddress ) and
  429.             ( TEAddress( Visited ).ObjectState = posDelete ) ;
  430. end;
  431.  
  432. //------------------------------------------------------------------------------
  433. procedure TVisEAdrsDelete.Init;
  434. begin
  435.   Query.SQL.Text := cSQLPersonEAddressDelete ;
  436. end;
  437.  
  438. //------------------------------------------------------------------------------
  439. procedure TVisEAdrsDelete.SetupParams;
  440. begin
  441.   Query.ParamByName( 'OID' ).AsInteger := TEAddress( Visited ).OID ;
  442. end;
  443.  
  444. //------------------------------------------------------------------------------
  445. procedure TVisEAdrsDelete.UpdateObject;
  446. begin
  447.   TEAddress( Visited ).ObjectState := posDeleted ;
  448. end;
  449.  
  450. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  451. // *
  452. // * TVisEAdrsUpdate
  453. // *
  454. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  455. function TVisEAdrsUpdate.AcceptVisitor: boolean;
  456. begin
  457.   result := ( Visited is TEAddress ) and
  458.             ( TEAddress( Visited ).ObjectState = posUpdate ) ;
  459. end;
  460.  
  461. procedure TVisEAdrsUpdate.Init;
  462. begin
  463.   Query.SQL.Text := cSQLPersonEAddressUpdate ;
  464. end;
  465.  
  466. procedure TVisEAdrsUpdate.SetupParams;
  467. begin
  468.   with Visited as TEAddress do begin
  469.     Query.ParamByName( 'OID' ).AsInteger       := OID ;
  470.     Query.ParamByName( 'Owner_OID' ).AsInteger := Owner.OID ;
  471.     Query.ParamByName( 'EAdrs_Type' ).AsString := EAdrsType ;
  472.     Query.ParamByName( 'Text' ).AsString       := Text ;
  473.   end ;
  474. end;
  475.  
  476. procedure TVisEAdrsUpdate.UpdateObject;
  477. begin
  478.   TEAddress( Visited ).ObjectState := posClean ;
  479. end;
  480.  
  481. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  482. // *
  483. // * TVisAdrsCreate
  484. // *
  485. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  486. function TVisAdrsCreate.AcceptVisitor: boolean;
  487. begin
  488.   result := ( Visited is TAddress ) and
  489.             ( TEAddress( Visited ).ObjectState = posCreate ) ;
  490. end;
  491.  
  492. procedure TVisAdrsCreate.Init;
  493. begin
  494.   Query.SQL.Text := cSQLPersonAddressCreate ;
  495. end ;
  496.  
  497. procedure TVisAdrsCreate.SetupParams;
  498. begin
  499.   with Visited as TAddress do begin
  500.     Query.ParamByName( 'oid'       ).AsInteger := OID ;
  501.     Query.ParamByName( 'owner_oid' ).AsInteger := Owner.OID ;
  502.     Query.ParamByName( 'adrs_type' ).AsString  := AdrsType ;
  503.     Query.ParamByName( 'lines'     ).AsString  := Lines ;
  504.     Query.ParamByName( 'state'     ).AsString  := State ;
  505.     Query.ParamByName( 'pcode'     ).AsString  := PCode ;
  506.     Query.ParamByName( 'country'   ).AsString  := Country ;
  507.   end ;
  508. end;
  509.  
  510. procedure TVisAdrsCreate.UpdateObject;
  511. begin
  512.   TAddress( Visited ).ObjectState := posClean ;
  513. end;
  514.  
  515. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  516. // *
  517. // * TVisAdrsUpdate
  518. // *
  519. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  520. function TVisAdrsUpdate.AcceptVisitor: boolean;
  521. begin
  522.   result := ( Visited is TAddress ) and
  523.             ( TEAddress( Visited ).ObjectState = posUpdate ) ;
  524. end;
  525.  
  526. procedure TVisAdrsUpdate.Init;
  527. begin
  528.   Query.SQL.Text := cSQLPersonAddressUpdate ;
  529. end;
  530.  
  531. procedure TVisAdrsUpdate.SetupParams;
  532. begin
  533.   with Visited as TAddress do begin
  534.     Query.ParamByName( 'oid'       ).AsInteger := OID ;
  535.     Query.ParamByName( 'owner_oid' ).AsInteger := Owner.OID ;
  536.     Query.ParamByName( 'adrs_type' ).AsString  := AdrsType ;
  537.     Query.ParamByName( 'lines'     ).AsString  := Lines ;
  538.     Query.ParamByName( 'state'     ).AsString  := State ;
  539.     Query.ParamByName( 'pcode'     ).AsString  := PCode ;
  540.     Query.ParamByName( 'country'   ).AsString  := Country ;
  541.   end ;
  542. end;
  543.  
  544. procedure TVisAdrsUpdate.UpdateObject;
  545. begin
  546.   TAddress( Visited ).ObjectState := posClean ;
  547. end;
  548.  
  549. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  550. // *
  551. // * TVisAdrsDelete
  552. // *
  553. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  554. function TVisAdrsDelete.AcceptVisitor: boolean;
  555. begin
  556.   result := ( Visited is TAddress ) and
  557.             ( TEAddress( Visited ).ObjectState = posDelete ) ;
  558. end;
  559.  
  560. procedure TVisAdrsDelete.Init;
  561. begin
  562.   Query.SQL.Text := cSQLPersonAddressDelete ;
  563. end;
  564.  
  565. procedure TVisAdrsDelete.SetupParams;
  566. begin
  567.   with Visited as TAddress do begin
  568.     Query.ParamByName( 'oid'       ).AsInteger := OID ;
  569.   end ;
  570. end;
  571.  
  572. procedure TVisAdrsDelete.UpdateObject;
  573. begin
  574.   TAddress( Visited ).ObjectState := posDeleted ;
  575. end;
  576.  
  577. initialization
  578.   gVisitorCache.RegisterVisitor( cgsAdrs_Read_PK, TVisPersonRead_PK ) ;
  579.  
  580.   // The order of these is important as ObjectState is set to pkClean in
  581.   // TVisPersonRead_Detail, and TVisAdrsRead and TVisEAdrsRead will only be
  582.   // read if objectState = posPK
  583.   gVisitorCache.RegisterVisitor( cgsAdrs_Read_Detail, TVisAdrsRead ) ;
  584.   gVisitorCache.RegisterVisitor( cgsAdrs_Read_Detail, TVisEAdrsRead ) ;
  585.   gVisitorCache.RegisterVisitor( cgsAdrs_Read_Detail, TVisPersonRead_Detail ) ;
  586.  
  587.   gVisitorCache.RegisterVisitor( cgsAdrs_Update, TVisPersonCreate ) ;
  588.   gVisitorCache.RegisterVisitor( cgsAdrs_Update, TVisPersonUpdate ) ;
  589.  
  590.   gVisitorCache.RegisterVisitor( cgsAdrs_Update, TVisEAdrsUpdate ) ;
  591.   gVisitorCache.RegisterVisitor( cgsAdrs_Update, TVisEAdrsCreate ) ;
  592.   gVisitorCache.RegisterVisitor( cgsAdrs_Update, TVisEAdrsDelete ) ;
  593.  
  594.   gVisitorCache.RegisterVisitor( cgsAdrs_Update, TVisAdrsCreate ) ;
  595.   gVisitorCache.RegisterVisitor( cgsAdrs_Update, TVisAdrsUpdate ) ;
  596.   gVisitorCache.RegisterVisitor( cgsAdrs_Update, TVisAdrsDelete ) ;
  597.  
  598.   gVisitorCache.RegisterVisitor( cgsAdrs_Update, TVisPersonDelete ) ;
  599.  
  600. end.
  601.